home *** CD-ROM | disk | FTP | other *** search
/ SGI Varsity Update 1998 August / SGI Varsity Update 1998 August.iso / dist / dist6.5 / il_dev.idb / usr / include / il / ilSemaphore.h.z / ilSemaphore.h
C/C++ Source or Header  |  1998-07-29  |  2KB  |  70 lines

  1. #if 0 
  2.  
  3.     Copyright (c) 1991 SGI   All Rights Reserved
  4.     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI
  5.     The copyright notice above does not evidence any
  6.     actual or intended publication of such source code,
  7.     and is an unpublished work by Silicon Graphics, Inc.
  8.     This material contains CONFIDENTIAL INFORMATION that
  9.     is the property of Silicon Graphics, Inc. Any use,
  10.     duplication or disclosure not specifically authorized
  11.     by Silicon Graphics is strictly prohibited.
  12.     
  13.     RESTRICTED RIGHTS LEGEND:
  14.     
  15.     Use, duplication or disclosure by the Government is
  16.     subject to restrictions as set forth in subdivision
  17.     (c)(1)(ii) of the Rights in Technical Data and Computer
  18.     Software clause at DFARS 52.227-7013, and/or in similar
  19.     or successor clauses in the FAR, DOD or NASA FAR
  20.     Supplement.  Unpublished- rights reserved under the
  21.     Copyright Laws of the United States.  Contractor is
  22.     SILICON GRAPHICS, INC., 2011 N. Shoreline Blvd.,
  23.     Mountain View, CA 94039-7311
  24.  
  25. #endif
  26. /*
  27.     This class is an interface to the user mode semaphore services.
  28. */
  29. #ifndef _ilSemaphore_h_
  30. #define _ilSemaphore_h_
  31.  
  32. #include <il/ilDefs.h>
  33. #ifdef IL_MP
  34. #include <ulocks.h>
  35. #endif
  36.  
  37. class ilArena;
  38.  
  39. class ilSemaphore {
  40. public:
  41.     // external api: begin
  42.     ilSemaphore(int val=1);    // create semaphore with initial count of 'val'
  43.     ~ilSemaphore();        // free semaphore
  44.     
  45.     int set(int val);        // re-initialize semaphore to count of 'val'
  46.     int inc();            // perform 'v' operation
  47.     int dec(int wait=TRUE);    // perform 'p' operation
  48.     // external api: end
  49.     
  50.     int operator=(int val) { return set(val); }
  51.     int operator++() { return inc(); }
  52.     int operator--() { return dec(); }
  53.     
  54. #ifdef DEBUG
  55.     int test();        // Debug Only: test semaphore (return value)
  56. #endif
  57.  
  58. protected:
  59.     ilSemaphore(int val, ilArena* ar);
  60.     ilSemaphore(int val, usptr_t* h);
  61. #ifdef IL_MP
  62.     void init(int val);
  63.  
  64.     usema_t* sem;
  65.     usptr_t* handle;
  66. #endif
  67. };
  68.  
  69. #endif
  70.